package com.solution.common.redis;

import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;


/**
 * 替换redis 默认的jdk的序列化策略
 * @author lilp
 */
public class KryoRedisSerializer<T> implements RedisSerializer<T> {

	@Override
	public byte[] serialize(Object obj) throws SerializationException {
		return RedisSerializeUtils.kryoSerialize(obj);
	}

	
	@SuppressWarnings("unchecked")
	@Override
	public T deserialize(byte[] bytes) throws SerializationException {
		return (T) RedisSerializeUtils.kryoDeserialize(bytes);
	}
}